import Vue from 'vue'
import VueRouter from 'vue-router'
import store from '../store'
Vue.use(VueRouter)
const routes = [
    //H5
  {path: '/', name: '首页', meta: {keepAlive : true}, component: () => import('../views/home.vue')},
  {path: '/liveList', name: '直播列表', meta: {keepAlive : true}, component: () => import('../views/LiveList.vue')},
  {path: '/live', name: '直播', component: () => import('../views/Live.vue')},

    //PC
  {path: '/pchome', name: 'PC端首页', meta: {keepAlive : true}, component: () => import('../views/PC/pcHome.vue')},
  {path: '/pcliveList', name: 'PC端直播列表', meta: {keepAlive : true}, component: () => import('../views/PC/pcliveList.vue')},
  {path: '/pclive', name: 'PC端直播', component: () => import('../views/PC/pcLive.vue')},


  {path: '/day', name: '会议简介', component: () => import('../views/Day.vue')},
  {path: '/know', name: '会议须知', component: () => import('../views/Know.vue')},
  {path: '/onlineExhibitionHall', name: '线上展厅', component: () => import('../views/onlineExhibitionHall.vue')},


]

const router = new VueRouter({
  // mode: 'history',
  routes
})
router.beforeEach((to, from, next) => {
  if (to.path !== '/' && !store.state.homeStatus) {
    next({ path: '/', replace: true })
  } else {
    store.dispatch('loadHome', true)
    next();
  }
})

//  先进首页
export default router
